<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<link href="<c:url value='/admin/css/custom.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/admin/css/style.css'/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/validate.js'/>"></script>
<script type="text/javascript">
/* $(function(){
	$("#button").click(function(){
		var data = $("#pwdForm").serialize;
		jQuery.ajax({
			url: "updatepwd.action",
			type: "post",
			dataType:"html",
			data:data,
			async:false,
			success: function(jsondata){
				alert(jsondata);
				self.location.href = "${ctx}/admin/userlist.action";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
		    }
		});
	});
}); */

</script>
<style type="text/css">
<!--
body {
	background: #ffffff;
	margin-top:10px;
	margin-left:5px;
	margin-right:5px;
}
-->
</style>
<body>
<div class="EpmsSubTitle"><p><b>修改密码</b></p>
</div>
<form action="updatepwdadmin.action" method="post" id="pwdForm" onsubmit="return false;"> 
<input type="hidden" id="userId" name="userId" value="${admin.userId}">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
	<tr>
		<td class=EpmsTdTitle><b>会员ID</b></td>
		<td class="EpmsTdNoColor">
			<b>${admin.userAccount}</b>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>原来三级密码</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="thirdPassword" name="thirdPassword" value=""/>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>登录密码</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="password11" name="password11" value=""/>（为空则不修改密码）
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>登录密码确认</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="password12" name="password12" value=""/>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>二级密码</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="password21" name="password21" value=""/>（为空则不修改密码）
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>二级密码确认</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="password22" name="password22" value=""/>
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>三级密码</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="password31" name="password31" value=""/>（为空则不修改密码）
		</td>
	</tr>
	<tr>
		<td class=EpmsTdTitle>三级密码确认</td>
		<td class="EpmsTdNoColor">
			<input type="password" id="password32" name="password32" value=""/>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<input type="button" onclick="doSave();" name="button" id="button" value="密码重置" class="inputSubmit" />
		</td>
	</tr>
</table>
</form>
</body>
<script type="text/javascript">
function doSave(){
	$.ajaxSetup({cache:false});
	var checkFlg = true;
	checkFlg = checkFlg && validateEmpty_jquery("原来三级密码", "thirdPassword");
	//checkFlg = checkFlg && false;
	$.ajax({
		type:'POST',
		url: "chkthid.action",
		data: "thirdPassword="+$("#thirdPassword").val(),
		dataType:"html",
        async:false,  // 设置同步方式
        cache:false,
		success: function(data,status){
			if($.trim(data)!=''){
				setValidateErrorStyle_jquery($("#thirdPassword"));
				alert(data);
				checkFlg = checkFlg && false;
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
	checkFlg = checkFlg && validateEmpty_jquery("登录密码", "password11");
	checkFlg = checkFlg && validateEmpty_jquery("确认登录密码", "password12");
	//alert($("#firstPwd").val()+"--"+$("#firstPwd2").val());
	if($("#password11").val() != $("#password12").val()){
		setValidateErrorStyle_jquery($("#password11"));
		setValidateErrorStyle_jquery($("#password12"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	if($("#password21").val() != $("#password22").val()){
		setValidateErrorStyle_jquery($("#password21"));
		setValidateErrorStyle_jquery($("#password22"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	if($("#password31").val() != $("#password32").val()){
		setValidateErrorStyle_jquery($("#password31"));
		setValidateErrorStyle_jquery($("#password32"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	if ( !checkFlg ) return false;
    if (checkFlg) {
    	//var data = $("#othermember").formSerialize();
    	var data = $("#pwdForm").serialize();
		jQuery.ajax({
			url: "updatepwd.action",
			type: "post",
			dataType:"html",
			data:data,
			async:false,
			success: function(jsondata){
				alert(jsondata);
				self.location.href = "${ctx}/admin/toupdatepwd.action?type=1";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
		    }
		});
    }
}
</script>